<%-- 
    Document   : penyata_kad_form
    Created on : Jun 19, 2014, 3:41:27 PM
    Author     : hasnor
--%>

<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>Semakan Penyata Kad</title>
        
         <script type="text/javascript">
            $(document).ready(function(){
//                $('form').submit( function () {
//                    return formValidation();
//                }); 
                
                $('#noAkaunDari').change(function(){                    
                    var url = '${pageContext.request.contextPath}/deposit?getNoKP' ;
                    $.get(url, 
                    {
                        noAkaun:$(this).val()
                    }, 
                    function(data){
                        $('#noKp').val(data);
                    }, "text");
                });
                
                function getLastMonths(n) {
    
                    var months = new Array();

                    var today = new Date();
                    var year = today.getFullYear();
                    var month = today.getMonth() + 1;
                   

                    var i = 0;
                    do {
                        //months.push(year + (month > 9 ? "" : "0") + month);
                        //months.push(month + (year + (month > 9 ? "" : "0")));
                        months.push((month > 9 ? "" : "0") + month + " - "+ year);
                        // 06 - 2014
                        if(month == 1) {
                            month = 12;
                            year--;
                        } else {
                            month--;
                        }
                        i++;
                    } while(i < n);

                    return months;

                }


                function writeMonthOptions() {   

                   var optionValues = getLastMonths(3);
                   var dropDown = document.getElementById("bulanPilihan");

                   for(var i=0; i<optionValues.length; i++) {
                       //var key = optionValues[i].slice(1,3);
                       var v = optionValues[i].slice(0,2)+optionValues[i].slice(5,9);//wil return MMyyyy format
                      // var key = optionValues[i]; ori
                       var key = v;
                       var value = optionValues[i];
                       dropDown.options[i] = new Option(value, key);
                    }

                }

                writeMonthOptions();
            });         
        </script>
    </head>
    <body>
        <s:form beanclass="th.stripes.action.DepositActionBean" class="niceform">
            <div id="content">
                <div id="logo">
                    <span>
                        <img src="${pageContext.request.contextPath}/images/img/ribbon.png"/>               
                    </span>
                </div>
                <h3>
                    Penyata <i>TH</i> DEBIT-<i>i</i> MASTERCARD
                </h3>  
               <p>
                    <label>No. Akaun TH :</label>
                    <s:select name="deposit.noAkaun" class="required" id="noAkaunDari">
                        <s:option value="">Sila Pilih</s:option>
                        <c:forEach items="${actionBean.accountList}" var="item">
                            <s:option value="${item.akaunTmbhn}">${item.akaunTmbhn}</s:option>
                        </c:forEach>
                    </s:select>
                </p>   
                <p>
                    <label>No. KP Semasa :</label>
                    <s:text name="deposit.noKp" id="noKp" readonly="true"/>
                </p>
                <p>
                    <label>Bulan :</label>
                    <s:select id="bulanPilihan" name="deposit.bulanPilihan">
                    </s:select>
                </p>   
                <p align="center">
                    <s:submit name="getPenyataKad" value="Semak"  class="button green button_blockUI"/>                    
                </p>                
            </div>
        </s:form>
    </body>
</html>
